<#assign module="company"/>

<@override name="header">
</@override>
<@override name="body">
<div class="row">

      <div class="col-xs-7">
        <form class="form-inline" role="form">
            <div class="form-group col-sm-6" style="padding-left:0px;">
                <input type="text" name="name" class="form-control" style="width:100%;" value="${name?if_exists}" placeholder="输入公司名称、拼音首字母、简称">
            </div>
            <button type="submit" class="btn btn-primary"><i class="icon-search"></i>&nbsp;搜索</button>
        </form>
      </div>
      <div class="col-xs-5">
      	<@shiro.hasPermission name='companyadd'>
      		<button class="pull-right button button-rounded button-flat-blue" onclick="window.location='${ctx}/company/add';"><i class="icon-plus"></i>&nbsp;添加子公司</button>
      	</@shiro.hasPermission>
      </div>
  </div>

<div class="row margin-top">
	<div class="col-xs-12">
	<div class="panel panel-primary">
	<div class="table-responsive">
		<table class="table table-hover table-striped">
			<thead>
			<tr style="font-size:14px;">
				<th>公司名称</th>
				<th>公司简称</th>
				<th>联系电话</th>
				<th>负责人</th>
				<th>手机号码</th>
				<th>公司地址</th>
				<th>代驾收费</th>
				<@zhuan>
					<th>专车收费</th>
				</@zhuan>
				<@pao>
					<th>跑腿收费</th>
				</@pao>
				<th>创建时间</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody>
				<#if (page.content)?? >
			  	<#list page.content as data>
					<tr>
						<td>
							${data.companyName?if_exists}
							<#if data.companyType>
								<font style="color:red;font-weight:700;">（主公司）</font>
							</#if>
						</td>
						<td>${data.abbreviation?if_exists}</td>
						<td>${data.telephone?if_exists}</td>
						<td>${data.manager?if_exists}</td>
						<td>${data.mobilePhone?if_exists}</td>
						<td>${data.cityName?if_exists} - ${data.companyAddress?if_exists}</td>
						<td>
							<#if data.area??>
								${data.area.name}
							<#else>
								-
							</#if>
						</td>
						<@zhuan>
							<td>
								<#if data.areaCar??>
									${data.areaCar.name}
								<#else>
									-
								</#if>
							</td>
						</@zhuan>
						<@pao>
							<td>
								<#if data.areaPaotui??>
									${data.areaPaotui.name}
								<#else>
									-
								</#if>
							</td>
						</@pao>
						<td>
							${data.created?datetime}
						</td>
						<td>
							<a href="${ctx}/company/edit/${data.id}" class="btn-link">编辑</a>
							<a href="${ctx}/company/setting/${data.id}" class="btn-link">设置</a>
						</td>
					</tr>
				</#list>
				</#if>
			</tbody>
		</table>
		<#if page.totalElements??>
		<ul class="pagination pull-right pagination-sm">
			<li><a>共 ${page.totalElements} 条数据</a></li>
			<@pg.pager items=page.totalElements?number maxPageItems=20 export="currentPageNumber=pageNumber" url="${ctx}/company/list">
				<@pg.param name="name" value="${name?if_exists}"/>
				<@pg.index>
					<@pg.first>
						<li><a href="${pageUrl}">&laquo;</a></li>
					</@pg.first>
					<@pg.prev>
						<li><a href="${pageUrl}">&lsaquo;</a></li>
					</@pg.prev>
					<@pg.pages>
						<#if  currentPageNumber == pageNumber >
							<li class="active"><a href="#">${pageNumber}</a></li>
						<#else>
							<li><a href="${pageUrl}">${pageNumber}</a></li>
						</#if>
					</@pg.pages>
					<@pg.next>
						<li><a href="${pageUrl}">&rsaquo;</a></li>
					</@pg.next>
					<@pg.last>
						<li><a href="${pageUrl}">&raquo;</a></li>
					</@pg.last>
				</@pg.index>
			</@pg.pager>
		</ul>
		</#if>
	</div>
	</div>
	</div>
</div>
</@override>
<@override name="footer">
	<script type="text/javascript">
		window.daijia = {
			ctx:'${ctx}',
			userId:'<@shiro.principal property='id'/>'
		};
	</script>
	<script src="${ctx}/assets/js/pushmessage.js"></script>
	<script type="text/javascript">
		var thisButton;
		function deleteCompany(){
			$.ajax({
				  type: 'POST',
				  url: ctx+'/company/delete/'+thisButton.attr("data-value"),
				  async: false,
				  dataType: "json",
				  success: function(data){
					  if(data.success){
						  thisButton.parent().parent().remove();
						  $.scojs_message('删除成功', $.scojs_message.TYPE_OK);
					  }
					  else{
						  $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
					  }
				  }
			});
		}
		
		$(document).ready(function(){
		    $(".deletethis").click(function(){
				thisButton = $(this);
				var confirm = $.scojs_confirm({
		            content: "删除该公司将删除该公司下所有服务人员和服务人员相关联的数据， 确定要删除吗？",
		            action:deleteCompany
		        });
		        confirm.show();
			});
		});
	</script>
</@override>
<@extends name="../layout.ftl"/>